package com.doubao.wechat.feign;

import com.doubao.common.result.Result;
import com.doubao.wechat.feign.dto.UserDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 用户服务Feign客户端
 */
@FeignClient(name = "doubao-user", path = "/user", url = "${feign.client.url.user:}", fallback = UserFeignClientImpl.class)
public interface UserFeignClient {

    /**
     * 根据ID获取用户信息
     */
    @GetMapping("/info/{userId}")
    Result<UserDTO> getUserById(@PathVariable("userId") Long userId);

    /**
     * 更新用户头像
     */
    @PutMapping("/avatar")
    Result<Void> updateUserAvatar(@RequestParam("userId") Long userId,
                                  @RequestParam("avatarUrl") String avatarUrl);

    /**
     * 校验用户是否存在
     */
    @GetMapping("/exists/{userId}")
    Result<Boolean> checkUserExists(@PathVariable("userId") Long userId);

    /**
     * 获取用户当前头像
     */
    @GetMapping("/avatar/{userId}")
    Result<String> getUserAvatar(@PathVariable("userId") Long userId);

    /**
     * 绑定用户微信信息
     *
     * @param userId   用户ID
     * @param openid   微信openid
     * @param unionid  微信unionid
     * @return 绑定结果
     */
    @PostMapping("/api/v1/users/{userId}/wechat/bind")
    Result<Void> bindUserWechatInfo(
            @PathVariable("userId") Long userId,
            @RequestParam("openid") String openid,
            @RequestParam(value = "unionid", required = false) String unionid);
            
    /**
     * 激活会员
     *
     * @param userId 用户ID
     * @param levelId 会员等级ID
     * @param subscriptionType 订阅类型
     * @param days 有效天数
     * @param source 来源
     * @param orderId 订单ID
     * @return 激活结果
     */
    @PostMapping("/api/v1/membership/activate")
    Result<Void> activateMembership(
            @RequestParam("userId") Long userId,
            @RequestParam("levelId") Integer levelId,
            @RequestParam("subscriptionType") String subscriptionType,
            @RequestParam("days") Integer days,
            @RequestParam("source") String source,
            @RequestParam("orderId") String orderId);
}